cc.Class({
    extends: cc.Component,

    properties: {
        show:cc.Label,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        if(cc.coinWin >= 0){
            this.show.string = '+' + cc.coinWin;
        }else{
            this.show.string = cc.coinWin;
        }
        this.collectCoin = false;
    },
    ads(){

    },
    collect(){
        if(this.collectCoin) return;
        this.collectCoin = true;
        cc.voicePlay.playEffect('click');
        var money = cc.sys.localStorage.getItem("money")/1 + cc.coinWin;
        cc.configData.money = cc.configData.money + cc.coinWin;
        if(cc.configData.money <= 0){
            cc.configData.money = 0;
            money = 0;
        }
        cc.sys.localStorage.setItem("money",money);
        console.log('money',money);
        cc.find('Canvas').emit('money');
        if(CC_JSB){
            this.scheduleOnce(function(){
                this.node.active = false;
                cc.director.loadScene('cookingFever1');
            },0.3)
        }else{
            cc.sdkbox.setDataAsync(cc.configData,function(){
                this.scheduleOnce(function(){
                    console.log('存储成功',cc.configData);
                    this.node.active = false;
                    cc.director.loadScene('cookingFever1');
                },0.3)
            }.bind(this));
        }
    },
    // update (dt) {},
});
